package com.bwie.controller;

import com.bwie.pojo.TbGood;
import com.bwie.service.TbGoodService;
import com.bwie.utils.Result;
import com.bwie.vo.PageGoodVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/good/index")
public class IndexController {


    @Autowired
    TbGoodService tbGoodService;


    /**
     * @description 商品列表
     * @params [pageGoodVo]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/6/26 9:53
     */
    @PostMapping("/getGoodList")
    public Result getGoodList(@RequestBody PageGoodVo pageGoodVo){

        return tbGoodService.getGoodList(pageGoodVo);
    }


    /**
     * @description 字典白哦
     * @params [dicttypeId]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/6/26 9:57
     */

    @PostMapping("/getDictByTypeId/{dicttypeId}")
    public Result getDictByTypeId(@PathVariable("dicttypeId") Integer dicttypeId){

        return tbGoodService.getDictByTypeId(dicttypeId);

    }



    /**
     * @description 商品添加
     * @params [tbGood]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/6/26 10:34
     */
    @PostMapping("/SaveGoods")
    public Result SaveGoods(@RequestBody @Validated TbGood tbGood){

        return tbGoodService.SaveGoods(tbGood);
    }

    @PostMapping("/getShoppingList")
    public Result getShoppingList(){
        return tbGoodService.getShoppingList();
    }

    @PostMapping("/getSelectShoping/{goodId}")
    public Result getSelectShoping(@PathVariable("goodId") Integer goodId){

        return tbGoodService.getSelectShoping(goodId);
    }

    @PostMapping("/deletesById/{id}")
    public Result deletesById(@PathVariable("id") Integer id){
        return tbGoodService.deletesById(id);
    }
}
